package  
{
	import Util.Directions
	/**
	 * ...
	 * @author Thiago Árvore
	 */
	public class BulletManager 
	{
		private var bullets:Array;
		private var main:Main;
		
		public function BulletManager(main:Main) 
		{
			bullets = new Array();
			this.main = main;
		}
		
		public function createBullet(player:Player, speed:Number, direction:int)
		{
			var bullet:Bullet = new Bullet(speed, direction);
			
			bullet.x = player.x + player.width * player.scaleX;
			bullet.y = player.y + player.height / 2;
			
			this.main.addChild(bullet);
			
			this.bullets.push(bullet);
		}
		
		public function update()
		{
			for (var k:int = 0; k < bullets.length; k++)
			{
				bullets[k].update();
				
				if (bullets[k].x >= this.main.stage.stageWidth)
				{
					this.main.removeChild(bullets[k]);
					bullets.splice(k, 1);
				}
			}
		}
	}

}